package LeetCode.exercise;

public class LC_11 {
    public static void main(String[] args) {
        int[] height = {1,8,6,2,5,4,8,3,7};
        int res = Solution(height);
        System.out.println(res);
    }
    public static int Solution(int[] height){
        int left = 0, right = height.length - 1, res = 0;
        while (left!=right){
            int v = (right-left)*Math.min(height[right],height[left]);
            res = Math.max(v,res);
            if(left < right){
                left++;
            } else {
                right--;
            }
        }
        return res;
    }
}
